<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>
       <canvas id="cvs" width="400" height="400" style="border:1px solid red"></canvas>
    </div>
    <script>
       var canvas = document.getElementById('cvs');
       var ctx = canvas.getContext("2d");
       //设置坐标轴与画布的距离
       var padding = {
           top:10,
           left:10,
           bottom:20,
           right:10
       }
       //设置箭头的宽高
       var arrow = {
           width: 12,
           height: 20
       }
       // y轴顶点
       var Top = {
           x:padding.left,
           y:padding.top
       }
       //x轴顶点
       var Right = {
           x:canvas.width - padding.right,
           y:canvas.height - padding.bottom
       }
       //坐标原点
       var Origin = {
           x: padding.left,
           y: canvas.height - padding.bottom
       }
       
       //y轴箭头 左
       var y1 = {
           x: Top.x - arrow.width/2,
           y: Top.y + arrow.height
       } 
       var y2 = {
           x: Top.x + arrow.width/2,
           y: Top.y + arrow.height
       }
       //x轴箭头
       var x1 = {
           x: Right.x - arrow.height,
           y: Right.y - arrow.width/2 
       }
       var x2 = {
           x: Right.x - arrow.height,
           y: Right.y + arrow.width/2 
       }
       console.log(Top)
       console.log(Origin)
       console.log(Right)

       //连接坐标
       ctx.beginPath()
       ctx.moveTo(Top.x, Top.y)
       ctx.lineTo(Origin.x, Origin.y)
       ctx.lineTo(Right.x, Right.y)
       ctx.stroke()
       //连接y轴箭头
       ctx.beginPath()
       ctx.moveTo(y1.x, y1.y)
       ctx.lineTo(Top.x, Top.y)
       ctx.lineTo(y2.x, y2.y)
       ctx.stroke()
        //连接X轴箭头
       ctx.beginPath()
       ctx.moveTo(x1.x, x1.y)
       ctx.lineTo(Right.x, Right.y)
       ctx.lineTo(x2.x, x2.y)
       ctx.stroke()
    </script>
</body>
</html>